package com.crt.nexus.user.controller;

import com.crt.nexus.core.response.R;
import com.crt.nexus.domain.dtos.UserDto;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RefreshScope
@RestController
@RequiredArgsConstructor
@RequestMapping("/profiles")
@PreAuthorize("hasRole('USER')")
public class ProfileController {

    @Value("${foo.bar:}")
    private String foobar;

    @GetMapping
    public R<?> profile() {
        UserDto dto = new UserDto();
        dto.setUsername("Andy");
        dto.setTruename("ZhangKe");
        dto.setState("normal");
        dto.setBalance(BigDecimal.valueOf(10000));
        dto.setEnable(true);
        dto.setNote(foobar);
        return R.ok(dto);
    }

}
